# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.
#
# Original Maintainer on AUR: zwindl

pkgname=gdbgui
pkgver=438.773b916
pkgrel=1
epoch=1
pkgdesc='Browser-based gdb frontend using Flask and JavaScript to visually debug C, C++, Go, or Rust.'
groups=('blackarch' 'blackarch-debugger' 'blackarch-binary')
arch=('any')
url='https://github.com/cs01/gdbgui'
depends=('python' 'python-eventlet' 'python-flask' 'python-flask-socketio'
         'python-pygdbmi' 'python-pypugjs' 'python-enum-compat' 'python-gevent'
         'python-pygments' 'python-flask-compress' 'python-brotli' 'gdb')
makedepends=('git' 'python-setuptools' 'yarn')
license=('GPL3')
#source=("https://github.com/cs01/gdbgui/archive/refs/tags/v$pkgver.tar.gz"
source=("git+https://github.com/cs01/$pkgname.git"
        'setup.py.patch')
sha512sums=('SKIP'
            '2bf3adfbd5b294898e88f0adcf4763973f1699009b3a4d4b93bc1624158f204cf069b0699a41688036b76e4571ac4b396b162f5e114cb929d913ba0fb171405a')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname
  #patch -p1 < setup.py.patch
}

build() {
  cd $pkgname

  export NODE_OPTIONS=--openssl-legacy-provider
  yarn install
  yarn build

  python setup.py build
}

package() {
  cd $pkgname

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  find "$pkgdir" -type d -name tests -exec rm -rf {} +
  find "$pkgdir" -type d -name __pycache__ -exec rm -rf {} +
}

